package com.example.room.db

import androidx.room.Database
import androidx.room.RenameColumn
import androidx.room.RenameTable
import androidx.room.RoomDatabase
import androidx.room.migration.AutoMigrationSpec
import com.example.room.dao.UserInfoDao
import com.example.room.dao.VideoInfoDao
import com.example.room.table.UserDaoEntity
/**
 * 数据库实体
 */
@Database(
    entities = [UserDaoEntity::class],
    version = 1,
    exportSchema = false,
    autoMigrations = [
        //        AutoMigration(from = 1,to = 2, spec = AppDatabase.UserInfoAutoMigrations::class)
    ]//数据库升级
)

abstract class AppDatabase:RoomDatabase() {
//    abstract fun getUserInfoDao(): UserInfoDao
//    abstract fun getVideoInfoDao(): VideoInfoDao

    //升级修改表名
    @RenameTable(fromTableName = "video_table", toTableName = "video_info_table")
    class UserInfoAutoMigrations : AutoMigrationSpec

    @RenameColumn(tableName = "video_table", fromColumnName = "name", toColumnName = "video_name")
    class UserInfoColumnAutoMigration : AutoMigrationSpec
}